﻿var p = 0;
var q = false;
$(function () {
    for (var i = 0; i < d.length; i++) {
        $('#datas').append('<a href="javascript:;" class="aui-list-product-fl-item"><div class="aui-list-product-fl-img"><img src="' + d[i].ppic + '" alt=""></div><div class="aui-list-product-fl-text"><h3 class="aui-list-product-fl-title">' + d[i].pname + '</h3><div class="aui-list-product-fl-mes"><div><span class="aui-list-product-item-price"><em>¥</em>' + d[i].pprice.toFixed(2) + '</span></div><div class="aui-btn-purchase"><span>' + d[i].g[d[i].gg - 1].name + '　×' + d[i].num + '</span></div></div></div></a>');
        if (d[i].g[d[i].gg - 1].n != 1) {
            q = true;
        }
        p += d[i].pprice * d[i].num;
    }
    $('#AllTotal1').html('￥' + p.toFixed(2));
    $('#AllTotal2').html('￥' + p.toFixed(2));
});
function subs() {
    if (p == 0) {
        txttip('您的购物车是空的');
        return;
    }
    if (q) {
        txttip('您的购物车存在库存不足商品');
        return;
    }
    if (ac == '') {
        txttip('您尚未选择地址', function () { location.href = '/shop/select_address_upgrade?x=' + x + '&price_start=' + price_start; });
        return;
    }
    loading();
    $.post('/dos_m/add_upgrade_order', { addresscode: ac, info: $('#info').val(), x: x }, function (d) { eval(d); });
}
function ok(c) {
    if (c == '') {
        layer.closeAll();
        txttip('购物车存在缺货商品', function () { location.href = location.href; });
    }
    else {
        layer.closeAll();
        txttip('提交成功，正在转跳支付', function () { location.href = '/shop/prepay?ordercode=' + c; });
    }
}